using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class tbdonhangBUS
    {
        public static int Insert(tbdonhangDTO dh)
        {
            tbdonhangDAL tbdonhangDAL = new tbdonhangDAL();
            return tbdonhangDAL.Insert(dh);
        }
        public static void Update(tbdonhangDTO dh)
        {
            tbdonhangDAL tbdonhangDAL = new tbdonhangDAL();
            tbdonhangDAL.Update(dh);
        }
        public static void Delete(int iD)
        {
            tbdonhangDAL tbdonhangDAL = new tbdonhangDAL();
            tbdonhangDAL.Delete(iD);
        }
        public static tbdonhangDTOColection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            tbdonhangDAL tbdonhangDAL = new tbdonhangDAL();
            return tbdonhangDAL.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbdonhangDTOColection GETAll()
        {
            int t = 0;
            tbdonhangDAL tbdonhangDAL = new tbdonhangDAL();
            return tbdonhangDAL.GET("where 1=1", 0, 10, tbdonhangDTOColumn.Madh.ToString(), "ASC", out t);
        }
        public static tbdonhangDTO GetByID(int iD)
        {
            int t = 0;
            tbdonhangDAL dhDAL = new tbdonhangDAL();
            tbdonhangDTOColection donhangColection = dhDAL.GET("where " + tbdonhangDTOColumn.Madh.ToString() + " = " + iD.ToString(), 0, 0,
                tbdonhangDTOColumn.Makh.ToString(), "ASC", out t);
            if (donhangColection.Count == 1)
                return donhangColection[0];
            return null;
        }
    }
}
